<template>
	<view class="pages">
		<view class="form">
			<view class="inp">
				<text>抬头类型：</text>
				<view class="">
					<u-radio-group v-model="form.type">
						<u-radio  shape="square" label="企业单位"  :name="1"></u-radio>
						<u-radio  shape="square" label="个人/非企业" :name="2"></u-radio>
					</u-radio-group>	
 				</view>
			
			</view> 
			<view class="inp">
				<text>发票抬头：</text>
				<view class="">
					<input type="text" placeholder="请输入" v-model="form.title" />
 				</view>

			</view>
			<view class="inp">
				<text>发票税号 ：</text>
				<view class="">
					<input type="text" placeholder="请输入" v-model="form.title" />
 				</view>
			</view>
			<view class="inp">
				<text>更多内容  ：</text>
				<view class="">
					<input type="text" placeholder="请输入" v-model="form.title" />
				</view>
			</view>
		</view>
		 
		<view class="form">
			<view class="inp" @click="show=!show">
				<text>发票金额</text>
				<view class="">
					 325
				</view>
			</view>
		</view>
		<view style="font-size: 24rpx;color: #F93A59;line-height: 58rpx;">
			*开票金额不包含优惠券及积分兑换的抵扣额度
		</view>
		
		<view class="form">
			<view class="inp" @click="show=!show">
				<text>邮箱地址：</text>
				<view class="">
					<input type="text" placeholder="请输入" v-model="form.title" />  
					<image src="@/static/right.png" mode="widthFix"></image>  
				</view>
			</view>
		</view> 
		<view class="footer">
			<view :class="canup ? 'btn' : ''" @click="up">
				申请电子发票
			</view>
		</view>
	</view>
</template>

<script>
	import {
		diaryaddAPI,
		diarydetailAPI,
		diaryeditAPI
	} from "@/api/api.js"
	import pro from "@/utils/uploadImg.js"
	import { uploadtempFile } from "@/utils/upload.js"
 	export default {
		components:{
			 
		},
		data() {
			return {
				form: {
					record_time: "",
					admin_name: "",
					item_name: ""
				},
				imgArr: [],
				project_id: "",
				id: "",
				show:false
			}
		},
		computed: {
			canup() {
				if (this.form.record_time && this.form.admin_name && this.form.item_name) {
					return true
				}
				return false
			}
		},
		onLoad(option) {
			this.project_id = option.project_id

			if (option.id) {
				this.id = option.id
				this.getdata()
			}
		},
		methods: {
			signOut(flag){
				this.show=!this.show
				if(flag){
					
				}
				
			},
			changeAvatar(e) {
				console.log(e)
				var temp = e.detail.avatarUrl;
				uploadtempFile(temp).then(res => {
					this.avatarUrl = res
				})
			},
			getNickname(e) {
				console.log(e.detail.value)
				this.nickname = e.detail.value
			},
			up() {
				var data = {
					...this.form,
					photo_group: this.imgArr.join(","),
					project_id: this.project_id,
					id: this.id
				}
				var _this = this
				if (this.id) {
					diaryeditAPI(data).then(res => {
						uni.showToast({
							title: '编辑成功',
							success() {

								let pages = getCurrentPages(); // 当前页面  
								let beforePage = pages[pages.length - 2];
								uni.navigateBack({
									success: function() {
										beforePage.$vm.getrj();
									}
								})
							}
						})

					})
					return
				}
				diaryaddAPI(data).then(res => {
					uni.showToast({
						title: '日记上传成功',
						success() {
							// _this.tourl("/pageB/project/projectinfo?id="+_this.project_id+"&type=3")
							let pages = getCurrentPages(); // 当前页面
							let beforePage = pages[pages.length - 2];
							uni.navigateBack({
								success: function() {
									beforePage.$vm.getrj();
								}
							})
						}
					})

				})
			},
			 
			 
		 }
	}
</script>

<style lang="scss" scoped>
	.pages {
		padding: 30rpx;
		background-color: #F7F8FA;
		min-height: 100vh;
	}

	.avatar {
		width: 80rpx;
		height: 80rpx;
		border-radius: 50%;
		background-color: #efefef;

		padding: 0;
		display: flex;
		align-items: center;
		justify-content: center;

		image {
			width: 70rpx;
			height: 70rpx;
			border-radius: 50%;
		}

		text {
			color: #666;
			font-size: 20rpx;
		}
	}

	.form {
		background-color: #fff;
		border-radius: 20rpx;
		padding:20rpx 30rpx;
		margin-top: 20rpx;

		.inp {
			display: flex;
			align-items: center;
			justify-content: space-between;
			padding: 20rpx 0;

			>text {
				font-weight: 600;
				font-size: 32rpx;
				color: #333333;
				width: 200rpx;
			}

			view {
				display: flex;
				align-items: center;
				image {
					width: 40rpx;
					height: 40rpx;
					margin: 0 10rpx;
				}

				input {
					text-align: right;
				}
			}

		}
	}


	.footer {
		position: fixed;
		width: 100%;
		height: 96px;
		bottom: 0;
		left: 0;
		background: rgba(251, 252, 255, 0.90);
		box-shadow: 0px -1px 0px 0px rgba(0, 0, 0, 0.02);
		backdrop-filter: blur(16px);
		display: flex;
		align-items: center;
		justify-content: center;

		view {
			width: 620rpx;
			height: 90rpx;
			background-color: #dadada;
			border-radius: 16px;
			text-align: center;
			line-height: 90rpx;
			color: #fff;
		}

		.btn {
			background: linear-gradient(98deg, #ff5e18, #ff1818 100%);
		}
	}
</style>